<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <div th:replace="common/fragment::leftmenu"></div>
    <!--End 左侧导航-->

    <!--头部信息-->
    <div th:replace="common/fragment::header"></div>
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form action="" class="pull-right search-bar" method="get" role="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <input id="search-field" name="search_field" type="hidden" value="title">
                      <button aria-expanded="false" aria-haspopup="true"
                              class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="search-btn"
                              type="button">
                        名称 <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu">
                        <li><a data-field="title" href="javascript:void(0)" tabindex="-1">名称</a>
                        </li>
                      </ul>
                    </div>

                    <input class="form-control" id="keyword-find-rolename" name="keyword" placeholder="请输入名称" type="text"
                           value="">
                    <span class="input-group-btn">
                                              <button class="btn btn-primary" id="keyword-find-btn" onclick="keywordsearch()"
                                                      type="button">搜索</button>
                                            </span>

                  </div>
                </form>

                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" href="/role/addrole.do">
                    <i class="mdi mdi-plus"></i>
                    新增
                  </a>
                  <!--
                  <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                  <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                  <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                  -->
                </div>
              </div>
              <div class="card-body">
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                    <tr>
                      <!--<th>
                          <label class="lyear-checkbox checkbox-primary">
                              <input type="checkbox" id="check-all">
                              <span></span>
                          </label>
                      </th>-->
                      <th>序号</th>
                      <th hidden="hidden">id</th>
                      <th>角色名称</th>
                  <!--    <th>角色图标</th>-->
                      <th>角色状态</th>
                      <th>添加时间</th>
                      <th>修改时间</th>
                      <th>备注</th>
                      <th>操作</th>
                    </tr>
                    </thead>
                    <tbody th:each="rolePO:${roleList}">
                    <tr>

                      <!-- <td>
                           <label class="lyear-checkbox checkbox-primary">
                               <input type="checkbox" name="ids[]" value="1">
                               <span></span>
                           </label>
                       </td>-->
                      <td th:text="${rolePOStat.index+1}"></td>
                      <td hidden="hidden" th:text="${rolePO.id}"></td>


                      <td th:text="${rolePO.name}"></td>
                      <!--<td th:text="${rolePO.icon}"></td>-->
                      <th:block th:switch="${rolePO.status}">
                        <td th:case="'1'" th:text="启用" style="color: #0FB25F"></td>
                        <td th:case="'-1'" th:text="禁用" style="color: #985f0d;"></td>
                      </th:block>

                        <td th:text="${#dates.format(rolePO.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                      <td th:text="${#dates.format(rolePO.updateTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                      <td th:text="${rolePO.comment}"></td>

                      <td>
                        <div class="btn-group">
                          <a class="btn btn-xs btn-default"
                             data-toggle="tooltip"
                             th:href="'/role/editrole.do?id='+${rolePO.id}" title="编辑">
                            <i class="mdi mdi-pencil"></i>
                          </a>
                         <!-- <a class="btn btn-xs btn-default"
                             data-toggle="tooltip"
                             href="javascript:void(0)" th:onclick="deleterole([[ ${rolePO.id} ]] ,[[${rolePO.name}]])"
                             th:onclick="'javascript:deleterole(\''+${rolePO.id}+'\',\''+${rolePO.name}+'\')'"
                             title="删除">-->
                             <!--th:onclick="deleterole([[${rolePO.id}]] ,[[${rolePO.name}]])"-->
                          <a class="btn btn-xs btn-default"
                             data-toggle="tooltip"
                             th:onclick="deleterole([[${rolePO.id}]] ,[[${rolePO.name}]])"
                             title="删除">

                            <i class="mdi mdi-window-close"></i>
                          </a>
                        </div>
                      </td>
                    </tr>

                    </tbody>
                  </table>
                </div>
                <!--
                <ul class="pagination">
                  <li class="disabled"><span>«</span></li>
                  <li class="active"><span>1</span></li>
                  <li><a href="#1">2</a></li>
                  <li><a href="#1">3</a></li>
                  <li><a href="#1">4</a></li>
                  <li class="disabled"><span>...</span></li>
                  <li><a href="#!">14452</a></li>
                  <li><a href="#!">14453</a></li>
                  <li><a href="#!">»</a></li>
                </ul>
                -->
              </div>
            </div>
          </div>

        </div>

      </div>
    </main>
    <!--End 页面主要内容-->
    <!--End 页面主要内容-->
  </div>
</div>
<div th:replace="common/fragment::tail-script"></div>
<script type="text/javascript">
  // 删除角色
  function deleterole(roleid, rolename) {
    $.confirm({
      title: '确定删除？',
      content: '是否要删除角色: ' + rolename,
      type: 'orange',
      typeAnimated: false,
      buttons: {
        confirm: {
          text: '确认',
          action: function () {
            let data = {"id": roleid}
            post_ajax('/role/deleterole.ajax', data, '/role/rolelist.do')
          }
        },
        cancel: {
          text: '取消',
          action: function () {

          }
        }
      }
    });

  }

  function keywordsearch(){

  let rolename = $('#keyword-find-rolename').val()


    window.location = "/role/searchrole.do?name="+rolename+'&t='+new Date();

  }

  $(document).ready(
      // $(".delete-menu-btn").on('click', function (e) {
      //     e.preventDefault()
      //     let postid = $(this).attr('value')
      //     let data = {
      //         'postid': postid,
      //     }
      //
      //     post_ajax('/menu/deletemenu.ajax', data, '/menu/listmenu.do')
      //     // return false;
//})
  );

</script>
</body>
</html>